

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * Abstract Database class
 *
 * @version 2011-04-03 (converted to Java 2011-10-26)
 */
public abstract class Database {
    private String username;
    private String password;
    private String url;
    
    private Connection connection;
    private ResultSet resultset;

    /**
     * Close connection, return true if succesful
     * 
     * @return boolean
     * @throws SQLException
     */
    public abstract boolean close() throws SQLException;
    
    /**
     * Connect to database, return true if succesful
     * 
     * @return boolean
     * @throws SQLException
     */
    public abstract boolean connect() throws SQLException;

    /**
     * Execute SQL, return false if unsuccesful
     * 
     * @param sql
     * @return
     * @throws SQLException
     */
    public abstract boolean executeSQL(String sql) throws SQLException;

    /**
     * Execute Update SQL, return false if unsuccesful
     * 
     * @param sql
     * @return
     * @throws SQLException
     */
    public abstract boolean executeUpdateSQL(String sql) throws SQLException;

    /**
     * Return connection to the server
     * 
     * @return connection
     */
    public Connection getConnection() {
        return connection;
    }

    /**
     * Get the name of the database
     * 
     * @return dbname
     */

    /**
     * Return hostname
     * 
     * @return hostname
     */
    public String getUrl() {
        return url;
    }

    /**
     * Return the port of the host
     * 
     * @return hostport
     */

    /**
     * Return password
     * 
     * @return password
     */
    public String getPassword() {
        return password;
    }

    /**
     * Get result
     * 
     * @return ResultSet
     */
    public ResultSet getResultSet() {
        return resultset;
    }

    /**
     * Return username
     * 
     * 
     * @return username
     */
    public String getUsername() {
        return username;
    }
    
    /**
     * Return true if connected to DB-server
     * 
     * @return boolean
     * @throws SQLException
     */
    public abstract boolean isConnected() throws SQLException;
    
    /**
     * Load driver, return true if succesful
     * 
     * @return boolean
     * @throws ClassNotFoundException
     */
    public abstract boolean loadDriver() throws ClassNotFoundException;

    /**
     * Set connection
     * 
     * @param connection
     */
    public void setConnection(Connection connection) {
        this.connection = connection;
    }

    /**
     * Set the name of the database
     * 
     * @param dbname
     */
    public void setUrl(String url) {
        this.url = url;
    }

    /**
     * Set hostname
     * 
     * @param hostname
     */

    /**
     * Set the port of the host
     * 
     * @param hostport
     */

    /**
     * Set the password
     * 
     * @param password
     */
    public void setPassword(String password) {
        this.password = password;
    }
    
    /**
     * 
     */
    public void setResultSet(ResultSet resultset) {
        this.resultset = resultset;
    }

    /**
     * Set username
     * 
     * @param username
     */
    public void setUsername(String username) {
        this.username = username;
    }
}